//
//  RBCompeLiveHeaderView.m
//  RMMaterialRed
//
//  Created by XBWH on 2024/3/13.
//

#import "RBCompeLiveHeaderView.h"

@interface RBCompeLiveHeaderView ()
@property(strong,nonatomic)UIView *bgView;
@property(strong,nonatomic)UIView *topLineView;
@property(strong,nonatomic)UILabel *titleLabel;
@end

@implementation RBCompeLiveHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self rb_initViewUI];
        [self setNeedsLayout];
    }
    return self;
}
-(void)rb_initViewUI{
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.topLineView];
    [self.bgView addSubview:self.titleLabel];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
    [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.mas_equalTo(RBScaleWidth(10));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topLineView.mas_bottom).mas_offset(RBScaleWidth(15));
        make.width.mas_equalTo(RBScaleWidth(92));
        make.height.mas_equalTo(RBScaleWidth(36));
        make.centerX.mas_equalTo(0);
    }];
    self.titleLabel.layer.cornerRadius = RBScaleWidth(18);
    self.titleLabel.layer.masksToBounds = YES;
    self.titleLabel.layer.borderColor = RBColor(204, 204, 204).CGColor;
    self.titleLabel.layer.borderWidth = 0.5;
}

- (UIView *)bgView{
    if(_bgView==nil){
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UIView *)topLineView{
    if(_topLineView==nil){
        _topLineView = [[UIView alloc] init];
        _topLineView.backgroundColor = RBColor(245, 245, 245);
    }
    return _topLineView;
}
-(UILabel *)titleLabel{
    if(_titleLabel==nil){
        _titleLabel = [UILabel rb_labelWithTitle:@"文字直播" color:RBColor(51, 51, 51) font:RBPingFangMediumFont(15) alignment:NSTextAlignmentCenter];
    }
    return _titleLabel;
}

@end
